<template>
  <div>
    <van-swipe @change="onChange" v-for="(v,i) in newarr" :key="i">
      <van-swipe-item><img :src="v.glist[0].pic"/></van-swipe-item>
      <van-swipe-item><img :src="v.glist[0].pic1"/></van-swipe-item>
      <van-swipe-item><img :src="v.glist[0].pic2"/></van-swipe-item>
      <van-swipe-item><img :src="v.glist[0].pic3"/></van-swipe-item>
      <template #indicator>
        <div class="custom-indicator">{{ current + 1 }}/4</div>
        <span class="icon-jiantou iconfont" @click="fun()"></span>
        <img src="../../../public/img/24.webp" />
      </template>
    </van-swipe>
    <Tp></Tp>
    <Bo></Bo>
  </div>
</template>

<script>
import Tp from "../../components/hanchaobo/top.vue";
import Bo from "../../components/hanchaobo/bottom.vue"
import {getdata} from "../../api/getapi.js"
export default {
  // props:["newarr"],
  components: { Tp,Bo },
  data() {
    return {
      current: 0,
      arr:[],
      newarr:[]
    };
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
    fun(){
        this.$router.push("/dp")
    }
  },
  mounted() {
    console.log(this.$route.query.dataid);
    getdata("/api/shop/findGoodsByLid?lid=11", "get").then(ok => {
      console.log(ok.data);
      this.arr = ok.data;
      console.log(this.arr);
      
      this.newarr = this.arr.filter((v) => {
        if (v.glist[0].gid == this.$route.query.dataid) {
          return v;
        }
      });
      console.log(this.newarr);
      
    });
  }
};
</script>

<style scoped>
@import url("http://at.alicdn.com/t/font_2803014_0zvducx9h22.css");
.custom-indicator {
  position: absolute;
  right: 20px;
  bottom: 50px;
  padding: 2px 5px;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.1);
      border-radius: 20%;
}
img {
  width: 100%;
  height: 100%;
}
span {
  position: absolute;
  top: 0.4rem;
  font-size: 0.8rem;
  left: 0.6rem;
  color: grey;
}
</style>
